import 'package:codersun/pages/animation_page.dart';
import 'package:codersun/pages/clip_path_page.dart';
import 'package:codersun/pages/draggable_page.dart';
import 'package:codersun/pages/filter_page.dart';
import 'package:codersun/pages/flutter_easyrefresh_page/flutter_easyrefresh_page.dart';
import 'package:codersun/pages/flutter_swiper_page.dart';
import 'package:codersun/pages/flutter_toast_page.dart';
import 'package:codersun/pages/image_page.dart';
import 'package:codersun/pages/language_tour/async_await_page.dart';
import 'package:codersun/pages/language_tour/isolate_page.dart';
import 'package:codersun/pages/list_view_page.dart';
import 'package:codersun/pages/list_view_refresh_indicator_page.dart';
import 'package:codersun/pages/some_chowders_page.dart';
import 'package:flutter/material.dart';
import 'package:codersun/pages/good_detail_page.dart';
import 'package:codersun/pages/roots/home_page.dart';
import 'package:codersun/pages/roots/setting_page.dart';
import 'package:codersun/pages/roots/tabs.dart';
import 'package:codersun/user/login/login_page.dart';
import 'package:codersun/user/register/register_page.dart';
import 'package:codersun/user/register/register_auth_code_page.dart';
import 'package:codersun/user/register/register_set_pwd_page.dart';
import 'package:codersun/pages/custom_app_bar/custom_app_bar_page.dart';
import 'package:codersun/pages/custom_app_bar/custom_app_bar_another_method_page.dart';
import 'package:codersun/pages/personal_center_page.dart';
import 'package:codersun/pages/buttons.dart';
import 'package:codersun/pages/text_field_page.dart';
import 'package:codersun/pages/check_box_and_radio_and_switch_page.dart';
import 'package:codersun/pages/language_tour/function_page.dart';
import 'package:codersun/pages/language_tour/classes_page/classes_page.dart';
import 'package:codersun/pages/http_and_model_page.dart';
import 'package:codersun/pages/date_time_page.dart';
import 'package:codersun/pages/dialog_page.dart';
import 'package:codersun/pages/chip_page.dart';
import 'package:codersun/pages/data_table_page.dart';
import 'package:codersun/pages/language_tour/generic_page.dart';
import 'package:codersun/pages/libraries_page.dart';
import 'package:codersun/pages/stepper_page.dart';
import 'package:codersun/pages/state_management_page.dart';
import 'package:codersun/pages/sliver_page.dart';
import 'package:codersun/Pages/stream_page.dart';
import 'package:codersun/Pages/bloc_page/bloc_page.dart';
import 'package:codersun/pages/rx_dart_page/rx_dart_page.dart';

class RRouter {
  /// 路由表
  static final routes = {
    '/': (context) => Tabs(),
    '/goodDetailPage': (context, {arguments}) => GoodDetailPage(arguments: arguments),
    '/homePage': (context, {arguments}) => HomePage(arguments: arguments),
    '/settingPage': (context, {arguments}) => SettingPage(arguments: arguments),
    '/loginPage': (context, {arguments}) => LoginPage(arguments: arguments),
    '/registerPage': (context, {arguments}) => RegisterPage(arguments: arguments),
    '/registerAuthCodePage': (context, {arguments}) => RegisterAuthCodePage(arguments: arguments),
    '/registerSetPwdPage': (context, {arguments}) => RegisterSetPwdPage(arguments: arguments),
    '/customAppBarPage': (context, {arguments}) => CustomAppBarPage(arguments: arguments),
    '/customAppBarAnotherMethodPage': (context, {arguments}) => CustomAppBarAnotherMethodPage(arguments: arguments),
    '/personalCenterPage': (context, {arguments}) => PersonalCenterPage(arguments: arguments),
    '/buttonsPage': (context, {arguments}) => ButtonsPage(arguments: arguments),
    '/textFieldPage': (context, {arguments}) => TextFieldPage(arguments: arguments),
    '/checkBoxAndRadioAndSwitchPage': (context, {arguments}) => CheckBoxAndRadioAndSwitchPage(arguments: arguments),
    '/functionPage': (context, {arguments}) => FunctionPage(arguments: arguments),
    '/classesPage': (context, {arguments}) => ClassesPage(arguments: arguments),
    '/httpAndModelPage': (context, {arguments}) => HttpAndModelPage(arguments: arguments),
    '/dateTimePage': (context, {arguments}) => DateTimePage(arguments: arguments),
    '/dialogPage': (context, {arguments}) => DialogPage(arguments: arguments),
    '/chipPage': (context, {arguments}) => ChipPage(arguments: arguments),
    '/dataTablePage': (context, {arguments}) => DataTablePage(arguments: arguments),
    '/genericPage': (context, {arguments}) => GenericPage(arguments: arguments),
    '/librariesPage': (context, {arguments}) => LibrariesPage(arguments: arguments),
    '/stepperPage': (context, {arguments}) => StepperPage(arguments: arguments),
    '/stateManagementPage': (context, {arguments}) => StateManagementPage(arguments: arguments),
    '/sliverPage': (context, {arguments}) => SliverPage(arguments: arguments),
    '/streamPage': (context, {arguments}) => StreamPage(arguments: arguments),
    '/blocPage': (context, {arguments}) => BlocPage(arguments: arguments),
    '/rxDartPage': (context, {arguments}) => RxDartPage(arguments: arguments),
    '/animationPage': (context, {arguments}) => AnimationPage(arguments: arguments),
    '/isolatePage': (context, {arguments}) => IsolatePage(arguments: arguments),
    '/someChowdersPage': (context, {arguments}) => SomeChowdersPage(arguments: arguments),
    '/asyncAwaitPage': (context, {arguments}) => AsyncAwaitPage(arguments: arguments),
    '/imagePage': (context, {arguments}) => ImagePage(arguments: arguments),
    '/flutterSwiperPage': (context, {arguments}) => FlutterSwiperPage(arguments: arguments),
    '/listViewPage': (context, {arguments}) => ListViewPage(arguments: arguments),
    '/listViewRefreshIndicatorPage': (context, {arguments}) => ListViewRefreshIndicatorPage(arguments: arguments),
    '/flutterToastPage': (context, {arguments}) => FlutterToastPage(arguments: arguments),
    '/flutterEasyrefreshPage': (context, {arguments}) => FlutterEasyrefreshPage(arguments: arguments),
    '/clipPathPage': (context, {arguments}) => ClipPathPage(arguments: arguments),
    '/filterPage': (context, {arguments}) => FilterPage(arguments: arguments),
    '/draggablePage': (context, {arguments}) => DraggablePage(arguments: arguments),
  };

  /// 统一处理路由跳转
  static final Function(RouteSettings settings) onGenerateRoute = (RouteSettings settings) {
    MaterialPageRoute route;
    final String name = settings.name;
    final Function pageContentBuilder = RRouter.routes[name];
    if (pageContentBuilder != null) {
      if (settings.arguments != null) {
        route = MaterialPageRoute(builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
      } else {
        route = MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      }
    }
    return route;
  };
}
